Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
replace-ext
Advanced tools
The replace-ext npm package is a utility for replacing the extension of a file path string. It is particularly useful in build processes and file manipulation tasks where you need to change file extensions programmatically.
Replace File Extension
This feature allows you to replace the extension of a given file path. In the code sample, the extension of 'file.txt' is changed to '.md', resulting in 'file.md'.
const replaceExt = require('replace-ext');
const filePath = 'example/file.txt';
const newFilePath = replaceExt(filePath, '.md');
console.log(newFilePath); // Outputs: 'example/file.md'
The 'path' module is a built-in Node.js module that provides utilities for working with file and directory paths. It includes the 'path.format' and 'path.parse' methods, which can be used to achieve similar functionality to replace-ext by manually changing the file extension.
The 'upath' package is a utility for working with file paths across different operating systems. It provides methods like 'upath.changeExt' which can be used to change the file extension, similar to replace-ext. However, upath offers additional cross-platform path handling features.
Replaces a file extension with another one.
var replaceExt = require('replace-ext');
var path = '/some/dir/file.js';
var newPath = replaceExt(path, '.coffee');
console.log(newPath); // /some/dir/file.coffee
replaceExt(path, extension)
Replaces the extension from path
with extension
and returns the updated path string.
Does not replace the extension if path
is not a string or is empty.
replace-ext
for enterpriseAvailable as part of the Tidelift Subscription.
The maintainers of replace-ext
and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
MIT
FAQs
Replaces a file extension with another one.
The npm package replace-ext receives a total of 2,268,606 weekly downloads. As such, replace-ext popularity was classified as popular.
We found that replace-ext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.